<html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Hammerspoon docs: PopupTranslateSelection</title>
    <style type="text/css">
      a { text-decoration: none; }
      a:hover { text-decoration: underline; }
      th { background-color: #DDDDDD; vertical-align: top; padding: 3px; }
      td { width: 100%; background-color: #EEEEEE; vertical-align: top; padding: 3px; }
      table { width: 100% ; border: 1px solid #0; text-align: left; }
      section > table table td { width: 0; }
    </style>
    <link rel="stylesheet" href="docs.css" type="text/css" media="screen" />
  </head>
  <body>
    <header>
      <h1><a href="./index.html">docs</a> &raquo; PopupTranslateSelection</h1>
      <p>Show a popup window with the translation of the currently selected (or other) text</p>
<p>Supported language codes are listed at <a href="https://cloud.google.com/translate/docs/languages">https://cloud.google.com/translate/docs/languages</a></p>
<p>Download: <a href="https://github.com/Hammerspoon/Spoons/raw/master/Spoons/PopupTranslateSelection.spoon.zip">https://github.com/Hammerspoon/Spoons/raw/master/Spoons/PopupTranslateSelection.spoon.zip</a></p>

      </header>
      <h3>API Overview</h3>
      <ul>
        <li>Variables - Configurable values</li>
          <ul>
            <li><a href="#logger">logger</a></li>
            <li><a href="#popup_close_on_escape">popup_close_on_escape</a></li>
            <li><a href="#popup_size">popup_size</a></li>
            <li><a href="#popup_style">popup_style</a></li>
          </ul>
        <li>Methods - API calls which can only be made on an object returned by a constructor</li>
          <ul>
            <li><a href="#bindHotkeys">bindHotkeys</a></li>
            <li><a href="#translatePopup">translatePopup</a></li>
            <li><a href="#translateSelectionPopup">translateSelectionPopup</a></li>
          </ul>
      </ul>
      <h3>API Documentation</h3>
        <h4 class="documentation-section">Variables</h4>
          <section id="logger">
            <a name="//apple_ref/cpp/Variable/logger" class="dashAnchor"></a>
            <h5><a href="#logger">logger</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>PopupTranslateSelection.logger</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Variable</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Logger object used within the Spoon. Can be accessed to set the default log level for the messages coming from the Spoon.</p>
</td>
              </tr>
            </table>
          </section>
          <section id="popup_close_on_escape">
            <a name="//apple_ref/cpp/Variable/popup_close_on_escape" class="dashAnchor"></a>
            <h5><a href="#popup_close_on_escape">popup_close_on_escape</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>PopupTranslateSelection.popup_close_on_escape</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Variable</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>If true, pressing ESC on the popup window will close it. Defaults to <code>true</code></p>
</td>
              </tr>
            </table>
          </section>
          <section id="popup_size">
            <a name="//apple_ref/cpp/Variable/popup_size" class="dashAnchor"></a>
            <h5><a href="#popup_size">popup_size</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>PopupTranslateSelection.popup_size</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Variable</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p><code>hs.geometry</code> object representing the size to use for the translation popup window. Defaults to <code>hs.geometry.size(770, 610)</code>.</p>
</td>
              </tr>
            </table>
          </section>
          <section id="popup_style">
            <a name="//apple_ref/cpp/Variable/popup_style" class="dashAnchor"></a>
            <h5><a href="#popup_style">popup_style</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>PopupTranslateSelection.popup_style</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Variable</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Value representing the window style to be used for the translation popup window. This value needs to be a valid argument to <a href="http://www.hammerspoon.org/docs/hs.webview.html#windowStyle"><code>hs.webview.setStyle()</code></a> (i.e. a combination of values from <a href="http://www.hammerspoon.org/docs/hs.webview.html#windowMasks[]"><code>hs.webview.windowMasks</code></a>. Default value: <code>hs.webview.windowMasks.utility|hs.webview.windowMasks.HUD|hs.webview.windowMasks.titled|hs.webview.windowMasks.closable</code></p>
</td>
              </tr>
            </table>
          </section>
        <h4 class="documentation-section">Methods</h4>
          <section id="bindHotkeys">
            <a name="//apple_ref/cpp/Method/bindHotkeys" class="dashAnchor"></a>
            <h5><a href="#bindHotkeys">bindHotkeys</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>PopupTranslateSelection:bindHotkeys(mapping)</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Method</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Binds hotkeys for PopupTranslateSelection</p>
<p>Parameters:</p>
<ul>
<li>mapping - A table containing hotkey modifier/key details for the following items:<ul>
<li><code>translate</code> - translate the selected text without specifying source/destination languages (source defaults to auto-detect, destination defaults to your last choice or to English)</li>
<li><code>translate_to_&lt;lang&gt;</code> - translate the selected text to the given destination language. Source language will be auto-detected.</li>
<li><code>translate_from_&lt;lang&gt;</code> - translate the selected text from the given destination language. Destination language will default to your last choice, or to English.</li>
<li><code>translate_&lt;from&gt;_&lt;to&gt;</code> - translate the selected text between the given languages.</li>
</ul>
</li>
</ul>
<p>Sample value for <code>mapping</code>:</p>

<pre><code> {
    translate_to_en = { { "ctrl", "alt", "cmd" }, "e" },
    translate_to_de = { { "ctrl", "alt", "cmd" }, "d" },
    translate_to_es = { { "ctrl", "alt", "cmd" }, "s" },
    translate_de_en = { { "shift", "ctrl", "alt", "cmd" }, "e" },
    translate_en_de = { { "shift", "ctrl", "alt", "cmd" }, "d" },
 }</code></pre>
</td>
              </tr>
            </table>
          </section>
          <section id="translatePopup">
            <a name="//apple_ref/cpp/Method/translatePopup" class="dashAnchor"></a>
            <h5><a href="#translatePopup">translatePopup</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>PopupTranslateSelection:translatePopup(text, to, from)</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Method</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Display a translation popup with the translation of the given text between the specified languages</p>
<p>Parameters:</p>
<ul>
<li>text - string containing the text to translate</li>
<li>to - two-letter code for destination language. If <code>nil</code>, Google Translate will use your most recent selection, or default to English</li>
<li>from - two-letter code for source language. If <code>nil</code>, Google Translate will try to auto-detect it</li>
</ul>
<p>Returns:</p>
<ul>
<li>The PopupTranslateSelection object</li>
</ul>
</td>
              </tr>
            </table>
          </section>
          <section id="translateSelectionPopup">
            <a name="//apple_ref/cpp/Method/translateSelectionPopup" class="dashAnchor"></a>
            <h5><a href="#translateSelectionPopup">translateSelectionPopup</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>PopupTranslateSelection:translateSelectionPopup(to, from)</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Method</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Get the current selected text in the frontmost window and display a translation popup with the translation between the specified languages</p>
<p>Parameters:</p>
<ul>
<li>to - two-letter code for destination language. If <code>nil</code>, Google Translate will use your most recent selection, or default to English</li>
<li>from - two-letter code for source language. If <code>nil</code>, Google Translate will try to auto-detect it</li>
</ul>
<p>Returns:</p>
<ul>
<li>The PopupTranslateSelection object</li>
</ul>
</td>
              </tr>
            </table>
          </section>
  </body>
</html>